home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 62 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.2 KB  |  47 lines

  1. Path: shell1.eznet.net!not-for-mail
  2. From: armstron@eznet.net (Jon Armstrong)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: C   prog  problem
  5. Date: 2 Jan 1996 03:34:56 -0500
  6. Organization: E-Znet, Incorporated, Rochester, NY 14604 (716)-262-2485
  7. Message-ID: <4caqng$o9e@shell1.eznet.net>
  8. References: <5326.6569T1305T1672@infi.net> <805.6571T1295T2945@mbox3.swipnet.se>
  9. NNTP-Posting-Host: shell1.eznet.net
  10.  
  11. In article <805.6571T1295T2945@mbox3.swipnet.se>,
  12. Roland Bengtsson <roland.bengtsson@mbox3.swipnet.se> wrote:
  13.  
  14. > >:This command only supports charecters .Is there a integer to char function ?
  15. > >:A better way to display text to the screen?
  16. >
  17. >If you have SAS/C you have this function:
  18. >
  19. >    stci_d() - Convert an integer to a decimal string
  20.  
  21. Actually sprintf() might be a better (more portable) solution.
  22.  
  23. The following is only an example and is uncompiled/untested:
  24.  
  25. void func(char *s, int i)
  26. {
  27.   if(s)
  28.   {
  29.     sprintf(s,"%d",i);
  30.   }
  31. }
  32.  
  33. int main()
  34. {
  35.   char s0[100];
  36.  
  37.   s[0] = '\0';
  38.   func(&s0[0],5);
  39.   printf("[%s]\n",s0);
  40.   return 0;
  41. }
  42.  
  43. -- 
  44.                +----------------------------------------------+
  45. Regards... Jon | Armstrong | LPA Software, Inc. | jma@lpa.com |
  46.                +----------------------------------------------+
  47.